Powershell - Add user as Farm Admin

Follow these steps to provide permission for a user as the SharePoint Farm Administrator group member.


Applicable in SharePoint 2010/2013/2016
  1. Copy content into a ps1 file
  2. Change 1st & 2nd lines as necessary
  3. Run script to add user as admin

$username = "domain\username"

$webAppUrl = "http://<webappurl>/"

$centralAdmin = Get-SPWebApplication -IncludeCentralAdministration | ?{$_.DisplayName -eq "SharePoint Central Administration v4"}

$caWeb = Get-SPWeb -Identity $centralAdmin.Url

$farmAdministrators = $caWeb.SiteGroups["Farm Administrators"]

$farmAdministrators.AddUser($username, "", $username, "Configured via PowerShell")



$db = $centralAdmin.ContentDatabases[0]

Add-SPShellAdmin -UserName $username -database $db

Get-SPWebApplication $webAppUrl | Get-SPContentDatabase | ForEach-Object {

 Add-SPShellAdmin -UserName $username -database $_

}

Add-SPShellAdmin -UserName $username
Powershell - Add user as Farm Admin Powershell - Add user as Farm Admin Reviewed by Srikant N on Tuesday, April 26, 2016 Rating: 5

No comments :

Thanks for your time ! Have a great day.

Copyright 2016 (Srikant N). Powered by Blogger.